import 'package:flutter/material.dart';
import 'package:top_foundation/utils/ex/image.dart';
import 'package:top_foundation/utils/theme/theme.dart';
import 'package:whale/helper/utils/util.dart';

import '../../helper/component/base/casstle/index.dart';
import 'index.dart';

class CasstleDemoPage extends CasstlePage<CasstleDemoController>
    with SliverAppBarMixin {
  const CasstleDemoPage({Key? key}) : super(key: key);

  Widget buildHeader() {
    return IImage.net(
      url:
          'https://pics0.baidu.com/feed/5ab5c9ea15ce36d399ff70655b8ddc8ae850b17c.jpeg@f_auto?token=e1c5eef33d2e859b9cc38f6c310b606a',
      width: 1.sw,
      fit: BoxFit.cover,
    );
  }

  @override
  Widget buildUpdateTabBar(BuildContext context, bool isFloat) {
    return Container(
        color: Colors.white, child: super.buildUpdateTabBar(context, isFloat));
  }

  @override
  Widget indexPageBuilder(BuildContext context, int index,
      {ScrollPhysics? physics}) {
    // return Column(
    //   children: List.generate(
    //       30, (i) => TitleContentItemView(title: '第$index个页面--第$i行')),
    // );
    return MediaQuery.removePadding(
      context: context,
      removeTop: true, //去除顶部的空白
      child: ListView.builder(
        physics: physics,
        padding: EdgeInsets.symmetric(horizontal: 12.r),
        itemBuilder: (context, i) {
          return TitleContentItemView(
            title: '第$index个页面--第$i行',
            border: Border(
              bottom: ITheme.borderSide,
            ),
          );
        },
        itemCount: 30,
      ),
    );
  }

  Widget buildAppTitle() {
    return Text(
      '标题',
      style: ITheme.text.titleLarge,
    );
  }

  @override
  List<Widget> buildHeaderSliver(
      BuildContext context, bool innerBoxIsScrolled) {
    return [
      floatAppBar1(context,
          title: buildAppTitle(),
          body: buildHeader(),
          pinnedHeight: 250.r,
          floatChild: buildUpdateTabBar(context, true)),
    ];
  }
}
